<?php

namespace app\controller;

use app\BaseController;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;

class Root extends BaseController
{
	//网站全局配置
    protected $config=[
		"title"=>"博客魔法师",
		"icon"=>"icon.png",
		"nav"=>"首页to=/|分类to=/category",
		"navSelect"=>"首页"
		];
	//引用文件资源，回调函数将获得每个文件相对路径和绝对路径与文件后缀
	public function quoteFile($path,$callback){
		    $iterator = new RecursiveIteratorIterator(
		        new RecursiveDirectoryIterator($_SERVER['DOCUMENT_ROOT'].$path, RecursiveDirectoryIterator::SKIP_DOTS),
		        RecursiveIteratorIterator::SELF_FIRST
		    );
		    
		    foreach ($iterator as $file) {
		        if ($file->isFile()) {
					$filePath=$file->getRealPath();
					$callback($filePath,str_replace($_SERVER['DOCUMENT_ROOT']," ",$filePath),$file->getExtension());
		        }
		    }
	}
}
